//
//  PreviewPDFViewController.m
//  CGPDFTest
//
//  Created by Emo, on 2024/5/17.
//

#import "PreviewPDFViewController.h"
#import <QuickLook/QuickLook.h>

@interface PreviewPDFViewController () <QLPreviewControllerDelegate, QLPreviewControllerDataSource>

@end

@implementation PreviewPDFViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    QLPreviewController *qlVC = [[QLPreviewController alloc] init];
    qlVC.view.frame = self.view.bounds;
    qlVC.delegate = self;
    qlVC.dataSource = self;
    [self addChildViewController:qlVC];
    [self.view addSubview:qlVC.view];
    
    [qlVC reloadData];
}


- (NSInteger)numberOfPreviewItemsInPreviewController:(QLPreviewController *)controller {
    return 1;
}

- (id<QLPreviewItem>)previewController:(QLPreviewController *)controller previewItemAtIndex:(NSInteger)index {
    return [NSURL fileURLWithPath: self.filePath?:@""];
}


@end
